package ysc.cqnu.operdb.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;
import ysc.cqnu.operdb.entity.ReceiveUserInfo;
import ysc.cqnu.operdb.entity.User;

@Mapper
@Component
public interface UserMapper {
    @Select("select * from userlogin where id=#{id}")
    public User findById(Integer id);
    //登录注册验证邮箱
    @Select("select * from userlogin where name=#{name}")
    public User findByName(String name);
    //注册
    @Insert("insert into userlogin(name,password,emile,age,sex,userType,userImgSrc,recordDdate) values (#{name},#{password},#{emile},#{age},#{sex},#{userType},#{userImgSrc},#{recordDdate})")
    public int insertByName(ReceiveUserInfo receiveLogin);
    //修改密码
    @Update("update userlogin set password=#{value} where name=#{name}")
    public int updateValue(String value,String name);
    //验证邮箱和用户名
    @Select("select name from userlogin where name=#{name} and emile=#{emile}")
    public User checkByNameAndEmile(ReceiveUserInfo receiveLogin);
    //修改数据库中头像src
    @Update("update userlogin set userImgSrc=#{userImgSrc},age=#{age} ,sex=#{sex}, emile=#{emile} where name=#{name}")
    public int updateUserImg(String userImgSrc,String name,String age,String sex,String emile);
    //修改个人信息不带头像
    @Update("update userlogin set age=#{age} ,sex=#{sex}, emile=#{emile} where name=#{name}")
    public int updateUserInfo(String name,String age,String sex,String emile);
}
